package cn.edu.tbu.tydemo.core;

import cn.edu.tbu.tydemo.exception.REnum;
import cn.edu.tbu.tydemo.vo.R;
import lombok.Data;

@Data
public class RUtil {
    public static R success(Object object){
        R result=new R();
        result.setCode(1);
        result.setDate(object);
        result.setMsg("成功");
        return result;
    }
    public static R success(){
        return success(null);
    }

    public static R error(Integer code,String msg){
        R result=new R();
        result.setCode(code);
        result.setDate(null);
        result.setMsg(msg);
        return result;
    }
    public static R error(REnum rEnum){
        return error(rEnum.getCode(),rEnum.getMsg());
    }
}
